<!DOCTYPE html>
<html>

    <link rel="stylesheet" href="/static/laydate/theme/default/laydate.css">
	<script type="text/javascript" src="/static/laydate/laydate.js"></script>
	
<div id="stu" style="border:1px solid #555555;padding: 5px;margin: 4px;">
	<h2 th:text="${admin}" style="margin-left: 10%;color: #49a38f"></h2>
	<form action="admini/add" method="post" id="po">
		<div class="layui-form-item">
			<label class="layui-form-label">收取费用</label>
			<div class="layui-input-inline">
				<input type="text" id="money" name="money" placeholder="请输入收取的费用" autocomplete="off"  class="layui-input">
			</div>
		</div> 
		<div class="layui-form-item">
			<label class="layui-form-label">开始时间</label>
			<div class="layui-input-inline">
				<input type="text"  name="starttime" disabled="disabled"  autocomplete="off" oninput="no1(value)" id="qqwe"  class="layui-input" th:value="${times}">
			</div>
			<div class="layui-form-mid layui-word-aux" id="text1" ><span class="layui-icon layui-icon-chat">起始时间自动获取授权结束时间，若授权已过期，自动获取当前时间！</span></div> 
		</div> 
		
		<div class="layui-form-item">
			<label class="layui-form-label">请选择</label>
		    <div class="layui-input-block">
				<input type="radio" name="sex" value="nv"  id="a"  onclick="input1()"  checked>&emsp;&emsp;/&emsp;&emsp;
		     	<input type="radio" name="sex" value="nan" id="b" onclick="input2()">
		    </div>
		    <div class="layui-form-mid layui-word-aux" id="text1" style="float: none;margin-left: 8%">授权结束日期&emsp;/&emsp;授权天数</div> 
		  </div>
		
		<div class="layui-form-item and1" >
			<label class="layui-form-label">结束时间</label>
			<div class="layui-input-inline">
				<input type="date" id="yzy1" name="endtime" placeholder="请选择授权结束日期"  autocomplete="off"  class="layui-input">
			</div>
		</div> 
		
		<div class="layui-form-item and2" style="display:none">
			<label class="layui-form-label">授权天数</label>
			<div class="layui-input-inline">
				<input type="text" id="yzy2" name="number" placeholder="请选择授权天数" autocomplete="off"  class="layui-input" onkeyup="value=value.replace(/[^\d]/g,'')">
			</div>
		</div> 
		<input type="hidden" name="maxdate" th:value="${time}">
		<input type="hidden" name="admins" th:value="${adminid}">
		<button type="button" class="layui-btn" id="but" style="margin-left: 40%;" onclick="add1()">授予权限</button>
	</form>
</div>
<script type="text/javascript">
	layui.use('laydate', function(){
	  var laydate = layui.laydate;
	  laydate.render({
	    elem: '#maxdate' //指定元素
	  });
	});
	
	function input1(){
		$(".and1").show();
		$(".and2").hide();
		$("#a").attr("disabled", true);
		$("#b").attr("disabled", false);
		$("#yzy2").val("");
	}
	function input2(){
		$(".and2").show();
		$(".and1").hide();
		$("#b").attr("disabled", true);
		$("#a").attr("disabled", false);
		$("#yzy1").val("");
	}
	function add1(){
		var a1=$("input[name='money']").val();
		var a2=$("input[name='endtime']").val();
		var a3=$("input[name='number']").val();
		$("#qqwe").attr("disabled", false);
		if(a1!=""&&a2!=""){
			$("#po").submit()
			
		}else if(a1!=""&&a3!=""){
			$("#yzy1").val("2111-11-11");
			$("#po").submit()
		}else{
			alert("输入存在错入！请核对！");
		}
	}
</script>